<template>
  <div class="common-layout">
    <el-container class="common-container">
      <el-aside class="sidebar">
        <div class="sidebar-top">
          <img class="sidebar-ico" src="/favicon.ico" alt="ico"/>
        </div>
        <div class="sidebar-middle">
          <div class="sidebar-links">
            <SidebarButton to="/chat" :icon="chatIcon" label="对话"/>
            <SidebarButton to="/kb" :icon="kbIcon" label="知识库"/>
          </div>
        </div>
        <div class="sidebar-bottom">
          <div class="sidebar-divider"></div>
          <UserAvatar class="sidebar-avatar"/>
        </div>
      </el-aside>
      <el-main class="main">
        <div class="main-content">
          <router-view/>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<script setup>
import UserAvatar from './components/UserAvatar.vue'
import SidebarButton from './components/SidebarButton.vue'

import chatIcon from '@/assets/images/chat.svg'
import kbIcon from '@/assets/images/kl.svg'
</script>

<style>
.common-layout {
  height: 100vh;
  padding: 0;
  margin: 0;
  position: relative;
}

.common-container {
  height: 100vh;
  margin: 0;
  padding: 0;
}

.main {
  padding: 0 !important;
}

.sidebar {
  width: 80px;
  max-width: 80px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 0;
  position: relative;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
}

.sidebar-top {
  margin-top: 20px;
  flex-shrink: 0;
}

.sidebar-middle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.sidebar-ico {
  width: 40px;
  height: 40px;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar a {
  font-weight: bold;
  color: #2c3e50;
  text-decoration: none;
  text-align: center;
}

.sidebar a.router-link-exact-active {
  color: #42b983;
}

.sidebar-avatar {
  margin-top: 10px;
}

.sidebar-divider {
  width: 55px;
  height: 1px;
  background: #dddddd;
}

.main-content {
  height: 100%;
  overflow: auto;
  box-sizing: border-box;
  padding: 8px 8px 8px 0;
}

</style>
